{%extends "issue_base.html"%}
{%block body%}

<script language="JavaScript" type="text/javascript"><!--
document.onkeydown = M_keyDown;
{%if user%}
logged_in = true;
{%else%}
logged_in = false;
login_warned = false;
{%endif%}
// -->
</script>

{%if user%}
<!-- Form used by in-line comment JS; XXX filled in by JS code -->
<form id="dainlineform" style="display: none;"
      action="{%url codereview.views.inline_draft%}" method="post">
  <div class="comment-border">
    <input type="hidden" name="snapshot" value="XXX">
    <input type="hidden" name="lineno" value="XXX">
    <input type="hidden" name="side" value="XXX">
    <input type="hidden" name="issue" value="{{issue.key.id}}">
    <input type="hidden" name="patchset" value="{{patchset.key.id}}">
    <input type="hidden" name="patch" value="{{patch.key.id}}">
    <textarea name="text" style="width:96%" rows="10"></textarea><br>
    <input type="submit" name="save" value="Save"
           onclick="return M_submitInlineComment(this.form);">
    <input type="reset" name="cancel" value="Cancel"
           onclick="M_removeTempInlineComment(this.form)">
  </div>
  <div class="comment-border" style="padding: 0pt;"></div>
</form>
<a id="resizer" style="display:none;cursor:pointer"><img src="{{media_url}}zippyplus.gif"></a>
{%endif%}

<div style="float: left;">
  <h2 style="margin-bottom: 0em; margin-top: 0em;">Unified Diff: {{patch.filename}}</h2>
  {%ifnotequal patch.nav_type "patch"%}
    <span style="color:red">Side-by-side diff isn't available for this file because of its large size.</span>
  {%endifnotequal%}
  <div style="margin-top: .2em;">{%include "issue_star.html"%}
    <b>Issue <a href="{%url codereview.views.show issue.key.id%}" onmouseover="M_showPopUp(this, 'popup-issue');" id="upCL">{{issue.key.id}}</a>:</b>
  {{issue.subject}} {%if issue.closed %} (Closed) {%endif%}
  {%if issue.base%}<span class="extra">Base URL: {{issue.base}}</span>{%endif%}</div>
  <div style="margin-top: .4em;">
    <b>Patch Set: {%if patchset.message%}{{patchset.message}}{%endif%}</b>
    <span class="extra">
    Created {{patchset.created|timesince}} ago
    {%if patchset.url%},
    Downloaded from: <a href="{{patchset.url}}">{{patchset.url}}</a>
    {%endif%}
    </span>
  </div>
  <div style="margin-top: .4em;" class="help">
    Use n/p to move between diff chunks;
    N/P to move between comments.
    {%if user%}
    Double-click a line to add a draft in-line comment.
    <br><span style="color:red">Draft comments are only viewable by you;</span>
    use <a href="{%url codereview.views.publish issue.key.id%}" class="novisit">Publish+Mail Comments</a> ('m') to let others view them.
    {%else%}
    Please Sign in to add in-line comments.
    {%endif%}
  </div>
</div>
{%if column_width and context%}
  <input type="hidden" id="id_context" value="{{context}}" />
  <input type="hidden" id="id_column_width" value="{{column_width}}" />
{%endif%}
<div style="float: right; color: #333333; background-color: #eeeeec; border: 1px solid lightgray; -moz-border-radius: 5px 5px 5px 5px; padding: 5px;">
  <div>
    Jump to: <select onchange="M_jumpToPatch(this, {{issue.key.id}}, {{patchset.key.id}}, true);">
      {% for jump_patch in patchset.patch_set %}
        <option value="{{jump_patch.key.id}}"
         {%ifequal jump_patch.key.id patch.key.id%} selected="selected"{%endifequal%}>{{jump_patch.filename}}</option>
      {% endfor %}
    </select>
  </div>
  {%if not patch.no_base_file%}
  <div style="margin-top: 5px;">
    <a href="{%url codereview.views.diff issue.key.id,patchset.key.id,patch.filename%}{%urlappend_view_settings%}">
    View side-by-side diff with in-line comments</a>
  </div>
  {%endif%}
  <div style="margin-top: 5px;">
    <a href="{%url codereview.views.download_patch issue.key.id,patchset.key.id,patch.key.id%}"
       title="Download patch for {{patch.filename}}">
      Download patch
    </a>
  </div>
  {%if user%}
  <div style="margin-top: 5px;">
    <a class="novisit" href="{%url codereview.views.publish issue.key.id%}">Publish+Mail
    Comments</a> ('m')
    |
    <a class="novisit" href="javascript:draftMessage.dialog_show()">Edit draft message</a> ('M')
  </div>
  {%endif%}
</div>
<div style="clear: both;"></div>

<div class="code" style="margin-top: 1.3em; display: table; margin-left: auto; margin-right: auto;">

<div class="codenav">
{%include "file_navigation.html"%} <br/>
<a href="javascript:M_expandAllInlineComments()">Expand Comments</a> ('e')
|
<a href="javascript:M_collapseAllInlineComments()">Collapse Comments</a> ('c')
|
<a name="show-all-inline"
   style="display:none"
   href="javascript:M_showAllInlineComments()">Show Comments</a>
<a name="hide-all-inline"
   href="javascript:M_hideAllInlineComments()">Hide Comments</a> ('s')
</div>

<div style="position:relative" id="table-top">

{%if patch.is_binary%}
<img src="{%url codereview.views.image issue.key.id,patchset.key.id,patch.key.id,1%}" />
{%else%}
<span id="hook-sel" style="display:none;"></span>

<table style="padding: 5px;" cellpadding="0" cellspacing="0" id="thecode"
       ondblclick="M_handleTableDblClick(event)"
       ontouchstart="M_handleTableTouchStart(event)"
       ontouchmove="M_handleTableTouchMove(event)"
       ontouchend="M_handleTableTouchEnd(event)">
{%for row in rows%}{{row|safe}}{%endfor%}
</table>
{%endif%}

</div>
<div class="codenav">
{%include "file_navigation.html"%}
</div>
</div>

<script language="JavaScript" type="text/javascript"><!--
var old_snapshot = "old";
var new_snapshot = "new";
var intraLineDiff = new M_IntraLineDiff();
var hookState = new M_HookState(window);
hookState.updateHooks();


// -->
</script>

{%include "draft_message.html"%}

{%endblock%}
